package com.itshare.video.mapper;

import com.itshare.video.pojo.po.UserRole;
import com.itshare.video.pojo.po.UserRoleExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.session.RowBounds;

public interface UserRoleMapper {
    long countByExample(UserRoleExample example);

    int deleteByExample(UserRoleExample example);

    @Delete({
        "delete from t_user_role",
        "where auto_id = #{autoId,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer autoId);

    @Insert({
        "insert into t_user_role (role_id, user_id)",
        "values (#{roleId,jdbcType=INTEGER}, #{userId,jdbcType=INTEGER})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="autoId", before=false, resultType=Integer.class)
    int insert(UserRole record);

    int insertSelective(UserRole record);

    List<UserRole> selectByExampleWithRowbounds(UserRoleExample example, RowBounds rowBounds);

    List<UserRole> selectByExample(UserRoleExample example);

    @Select({
        "select",
        "auto_id, role_id, user_id",
        "from t_user_role",
        "where auto_id = #{autoId,jdbcType=INTEGER}"
    })
    @ResultMap("com.itshare.video.mapper.UserRoleMapper.BaseResultMap")
    UserRole selectByPrimaryKey(Integer autoId);

    int updateByExampleSelective(@Param("record") UserRole record, @Param("example") UserRoleExample example);

    int updateByExample(@Param("record") UserRole record, @Param("example") UserRoleExample example);

    int updateByPrimaryKeySelective(UserRole record);

    @Update({
        "update t_user_role",
        "set role_id = #{roleId,jdbcType=INTEGER},",
          "user_id = #{userId,jdbcType=INTEGER}",
        "where auto_id = #{autoId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(UserRole record);
}